import 'dart:io';

import 'package:flutter/material.dart';
import 'package:people_big_people/base/base_scaffold.dart';
import 'package:webview_flutter/webview_flutter.dart';

class WebPage extends StatelessWidget {
  const WebPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    var arguments = ModalRoute.of(context)?.settings.arguments as Map<String, dynamic>;
    String url = arguments["url"] ?? "";
    return WebStateful(
      url: url,
    );
  }
}

class WebStateful extends StatefulWidget {
  String url;

  WebStateful({Key? key, required this.url}) : super(key: key);

  @override
  State<WebStateful> createState() => _WebStatefulState();
}

class _WebStatefulState extends State<WebStateful> {
  @override
  void initState() {
    super.initState();
    // Enable virtual display.
    if (Platform.isAndroid) WebView.platform = AndroidWebView();
  }

  @override
  Widget build(BuildContext context) {
    return BaseScaffold(body: SafeArea(child: WebView(
      initialUrl: widget.url,
    )));
  }
}
